Passed
Pull Request — master (#87)
by Mathieu
01:49
created

FileLocationStrategy   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 9
dl 0
loc 10
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A location 0 7 1
1
import {ConfigService} from '@nestjs/config';
2
3
export class FileLocationStrategy {
4
  constructor(private readonly configService: ConfigService) {}
5
6
  public async location(fileName: string, date: Date): Promise<string> {
7
    const destination = await this.configService.get<string>('UPLOAD_LOCATION');
8
    const month = date.getMonth() + 1;
9
    const year = date.getFullYear();
10
11
    return `${destination}/${year}/${month}/${fileName}`;
12
  }
13
}
14